#ifndef _RENDERTASK_H_
#define _RENDERTASK_H_

#include <functional>

namespace SEngine
{
    class RenderTask 
    {
    public:
        virtual ~RenderTask() = default;
        virtual void OnBeginFrame() = 0;
        virtual void OnDrawFrame() = 0;
        virtual void OnEndFrame() = 0;
    };

    class LambdaTask : public RenderTask
    {
    public:
        enum Where {
            BeginFrame = 0,
            DrawFrame = 1,
            EndFrame = 2,
        };
    public:
        LambdaTask(std::function<void(void)> && fn, Where where = DrawFrame) : m_fn(std::move(fn)), m_where(where) {}
        virtual void OnBeginFrame() override { if (m_where == BeginFrame) m_fn(); }
        virtual void OnDrawFrame() override { if (m_where == DrawFrame) m_fn(); }
        virtual void OnEndFrame() override { if (m_where == EndFrame) m_fn(); }
    private:
        std::function<void(void)> m_fn;
        Where m_where;
    };

} // namespace SEngine


#endif